package view;

import java.awt.Color;
import java.awt.Dimension;

import javax.swing.JLabel;

import model.Alive;
import model.Element;

public class ElementWrapper extends JLabel implements Alive{
	
	private Element element;
	private Map map;
	private boolean alive = true;
	
	public ElementWrapper(Element e, Map map){
		this.element = e;
		this.map = map;
		setOpaque(true);
		setBackground(e.getColor());
	}

	public void tick() {
		element.tick();
		Dimension d = new Dimension(element.getWidth(), element.getHeight());
		setSize(d);
		setPreferredSize(d);
		this.setLocation(element.getX()-map.getDX(), element.getY()-map.getDY());
	}

	public boolean isAlive() {
		return element.isAlive()&&alive;
	}

	public void kill() {
		alive = false;
	}

	public String toString(){
		return "ElementWrapper with "+element.toString();
	}

	public int getDepth() {
		return element.depth();
	}
	
}
